microbit = codesters.Microbit()
microbit.show_string("hello")
data = microbit.get_temp()
microbit.show_number(data)
data_list = []
time_list = []
my_display = codesters.ScatterPlot(time_list, data_list)
time = 0
def interval():
data = microbit.get_temp()
data_list.append(data)
global time
stage.event_interval(interval, 2)
t = codesters.Teacher()
appends = t.find_text('append')
try:
tval1 = appends[1][1]
tval2 = t.get_indent_at_line(appends[1][0])
except:
tval1 = "DNE"
tval2 = "DNE"
t1 = TestObjective()
t1.add_success('time_list.append(time)' in tval1 and tval2 == 4, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add an Append command in your interval event?")
t1.add_failure('time_list.' not in tval1, "Did you change the list name in the append command to time_list?")
t1.add_failure('(time)' not in tval1, "Did you change the variable in parentheses to time?")
t1.add_failure(tval2 < 4, "Make sure your Append command is indented INSIDE your interval event!")
t1.add_failure(tval2 > 4, "Make sure your Append command is indented ONLY 4 spaces inside your interval event.")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)